import request from '@/utils/request'

// 搜索售货机(售货机列表)
export const searchTable = (obj) => {
  return request.get('/api/vm-service/vm/search', {
    params: obj
  })
}

// 售货机类型列表(搜索) 下拉列表
export const searchDeviceType = () => {
  return request.get('/api/vm-service/vmType/search', {
    params: {
      pageIndex: 1,
      pageSize: 100000
    }
  })
}

// 点位搜索 下拉列表
export const searchNode = () => {
  return request.get('/api/vm-service/node/search', {
    params: {
      pageIndex: 1,
      pageSize: 100000
    }
  })
}

// 新增售货机
export const addDevice = (data) => {
  return request.post('/api/vm-service/vm', {
    createUserId: 1,
    ...data
  })
}

// 修改售货机点位
export const updateNode = (obj) => {
  return request.put(`/api/vm-service/vm/${obj.id}/${obj.nodeId}`)
}

// 策略列表 批量操作
export const policyList = () => {
  return request.get('/api/vm-service/policy')
}

// 应用策略
export const applyPolicy = (data) => {
  return request.put('/api/vm-service/vm/applyPolicy', data)
}

// 查询售货机策略
export const queryPolicy = (innerCode) => {
  return request.get(`/api/vm-service/policy/vmPolicy/${innerCode}`)
}

// 取消策略
export const cancelPolicy = (obj) => {
  return request.put(`/api/vm-service/vm/cancelPolicy/${obj.innerCode}/${obj.policyId}`)
}

// 货道接口
// 售货机类型详情
export const typeDetail = (typeId) => {
  return request.get(`/api/vm-service/vmType/${typeId}`)
}

// 获取售货机货道详情
export const goodsDetail = (innerCode) => {
  return request.get(`/api/vm-service/channel/channelList/${innerCode}`)
}

// 商圈列表
export const businessList = (businessId) => {
  return request.get(`/api/vm-service/businessType/name/${businessId}`)
}

// 获取商圈下销量前10的商品(补货推荐)
export const getTop10 = (businessId) => {
  return request.get(`/api/vm-service/sku/businessTop10/${businessId}`)
}
